/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package io.kubernetes.client.openapi.models;

import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Objects;

/** CronJobSpec describes how the job execution will look like and when it will actually run. */
@ApiModel(
    description =
        "CronJobSpec describes how the job execution will look like and when it will actually run.")
@javax.annotation.Generated(
    value = "org.openapitools.codegen.languages.JavaClientCodegen",
    date = "2020-07-29T18:17:00.375Z[Etc/UTC]")
public class V1beta1CronJobSpec {
  public static final String SERIALIZED_NAME_CONCURRENCY_POLICY = "concurrencyPolicy";

  @SerializedName(SERIALIZED_NAME_CONCURRENCY_POLICY)
  private String concurrencyPolicy;

  public static final String SERIALIZED_NAME_FAILED_JOBS_HISTORY_LIMIT = "failedJobsHistoryLimit";

  @SerializedName(SERIALIZED_NAME_FAILED_JOBS_HISTORY_LIMIT)
  private Integer failedJobsHistoryLimit;

  public static final String SERIALIZED_NAME_JOB_TEMPLATE = "jobTemplate";

  @SerializedName(SERIALIZED_NAME_JOB_TEMPLATE)
  private V1beta1JobTemplateSpec jobTemplate;

  public static final String SERIALIZED_NAME_SCHEDULE = "schedule";

  @SerializedName(SERIALIZED_NAME_SCHEDULE)
  private String schedule;

  public static final String SERIALIZED_NAME_STARTING_DEADLINE_SECONDS = "startingDeadlineSeconds";

  @SerializedName(SERIALIZED_NAME_STARTING_DEADLINE_SECONDS)
  private Long startingDeadlineSeconds;

  public static final String SERIALIZED_NAME_SUCCESSFUL_JOBS_HISTORY_LIMIT =
      "successfulJobsHistoryLimit";

  @SerializedName(SERIALIZED_NAME_SUCCESSFUL_JOBS_HISTORY_LIMIT)
  private Integer successfulJobsHistoryLimit;

  public static final String SERIALIZED_NAME_SUSPEND = "suspend";

  @SerializedName(SERIALIZED_NAME_SUSPEND)
  private Boolean suspend;

  public V1beta1CronJobSpec concurrencyPolicy(String concurrencyPolicy) {

    this.concurrencyPolicy = concurrencyPolicy;
    return this;
  }

  /**
   * Specifies how to treat concurrent executions of a Job. Valid values are: - \&quot;Allow\&quot;
   * (default): allows CronJobs to run concurrently; - \&quot;Forbid\&quot;: forbids concurrent
   * runs, skipping next run if previous run hasn&#39;t finished yet; - \&quot;Replace\&quot;:
   * cancels currently running job and replaces it with a new one
   *
   * @return concurrencyPolicy
   */
  @javax.annotation.Nullable
  @ApiModelProperty(
      value =
          "Specifies how to treat concurrent executions of a Job. Valid values are: - \"Allow\" (default): allows CronJobs to run concurrently; - \"Forbid\": forbids concurrent runs, skipping next run if previous run hasn't finished yet; - \"Replace\": cancels currently running job and replaces it with a new one")
  public String getConcurrencyPolicy() {
    return concurrencyPolicy;
  }

  public void setConcurrencyPolicy(String concurrencyPolicy) {
    this.concurrencyPolicy = concurrencyPolicy;
  }

  public V1beta1CronJobSpec failedJobsHistoryLimit(Integer failedJobsHistoryLimit) {

    this.failedJobsHistoryLimit = failedJobsHistoryLimit;
    return this;
  }

  /**
   * The number of failed finished jobs to retain. This is a pointer to distinguish between explicit
   * zero and not specified. Defaults to 1.
   *
   * @return failedJobsHistoryLimit
   */
  @javax.annotation.Nullable
  @ApiModelProperty(
      value =
          "The number of failed finished jobs to retain. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.")
  public Integer getFailedJobsHistoryLimit() {
    return failedJobsHistoryLimit;
  }

  public void setFailedJobsHistoryLimit(Integer failedJobsHistoryLimit) {
    this.failedJobsHistoryLimit = failedJobsHistoryLimit;
  }

  public V1beta1CronJobSpec jobTemplate(V1beta1JobTemplateSpec jobTemplate) {

    this.jobTemplate = jobTemplate;
    return this;
  }

  /**
   * Get jobTemplate
   *
   * @return jobTemplate
   */
  @ApiModelProperty(required = true, value = "")
  public V1beta1JobTemplateSpec getJobTemplate() {
    return jobTemplate;
  }

  public void setJobTemplate(V1beta1JobTemplateSpec jobTemplate) {
    this.jobTemplate = jobTemplate;
  }

  public V1beta1CronJobSpec schedule(String schedule) {

    this.schedule = schedule;
    return this;
  }

  /**
   * The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
   *
   * @return schedule
   */
  @ApiModelProperty(
      required = true,
      value = "The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.")
  public String getSchedule() {
    return schedule;
  }

  public void setSchedule(String schedule) {
    this.schedule = schedule;
  }

  public V1beta1CronJobSpec startingDeadlineSeconds(Long startingDeadlineSeconds) {

    this.startingDeadlineSeconds = startingDeadlineSeconds;
    return this;
  }

  /**
   * Optional deadline in seconds for starting the job if it misses scheduled time for any reason.
   * Missed jobs executions will be counted as failed ones.
   *
   * @return startingDeadlineSeconds
   */
  @javax.annotation.Nullable
  @ApiModelProperty(
      value =
          "Optional deadline in seconds for starting the job if it misses scheduled time for any reason.  Missed jobs executions will be counted as failed ones.")
  public Long getStartingDeadlineSeconds() {
    return startingDeadlineSeconds;
  }

  public void setStartingDeadlineSeconds(Long startingDeadlineSeconds) {
    this.startingDeadlineSeconds = startingDeadlineSeconds;
  }

  public V1beta1CronJobSpec successfulJobsHistoryLimit(Integer successfulJobsHistoryLimit) {

    this.successfulJobsHistoryLimit = successfulJobsHistoryLimit;
    return this;
  }

  /**
   * The number of successful finished jobs to retain. This is a pointer to distinguish between
   * explicit zero and not specified. Defaults to 3.
   *
   * @return successfulJobsHistoryLimit
   */
  @javax.annotation.Nullable
  @ApiModelProperty(
      value =
          "The number of successful finished jobs to retain. This is a pointer to distinguish between explicit zero and not specified. Defaults to 3.")
  public Integer getSuccessfulJobsHistoryLimit() {
    return successfulJobsHistoryLimit;
  }

  public void setSuccessfulJobsHistoryLimit(Integer successfulJobsHistoryLimit) {
    this.successfulJobsHistoryLimit = successfulJobsHistoryLimit;
  }

  public V1beta1CronJobSpec suspend(Boolean suspend) {

    this.suspend = suspend;
    return this;
  }

  /**
   * This flag tells the controller to suspend subsequent executions, it does not apply to already
   * started executions. Defaults to false.
   *
   * @return suspend
   */
  @javax.annotation.Nullable
  @ApiModelProperty(
      value =
          "This flag tells the controller to suspend subsequent executions, it does not apply to already started executions.  Defaults to false.")
  public Boolean getSuspend() {
    return suspend;
  }

  public void setSuspend(Boolean suspend) {
    this.suspend = suspend;
  }

  @Override
  public boolean equals(java.lang.Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    V1beta1CronJobSpec v1beta1CronJobSpec = (V1beta1CronJobSpec) o;
    return Objects.equals(this.concurrencyPolicy, v1beta1CronJobSpec.concurrencyPolicy)
        && Objects.equals(this.failedJobsHistoryLimit, v1beta1CronJobSpec.failedJobsHistoryLimit)
        && Objects.equals(this.jobTemplate, v1beta1CronJobSpec.jobTemplate)
        && Objects.equals(this.schedule, v1beta1CronJobSpec.schedule)
        && Objects.equals(this.startingDeadlineSeconds, v1beta1CronJobSpec.startingDeadlineSeconds)
        && Objects.equals(
            this.successfulJobsHistoryLimit, v1beta1CronJobSpec.successfulJobsHistoryLimit)
        && Objects.equals(this.suspend, v1beta1CronJobSpec.suspend);
  }

  @Override
  public int hashCode() {
    return Objects.hash(
        concurrencyPolicy,
        failedJobsHistoryLimit,
        jobTemplate,
        schedule,
        startingDeadlineSeconds,
        successfulJobsHistoryLimit,
        suspend);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class V1beta1CronJobSpec {\n");
    sb.append("    concurrencyPolicy: ").append(toIndentedString(concurrencyPolicy)).append("\n");
    sb.append("    failedJobsHistoryLimit: ")
        .append(toIndentedString(failedJobsHistoryLimit))
        .append("\n");
    sb.append("    jobTemplate: ").append(toIndentedString(jobTemplate)).append("\n");
    sb.append("    schedule: ").append(toIndentedString(schedule)).append("\n");
    sb.append("    startingDeadlineSeconds: ")
        .append(toIndentedString(startingDeadlineSeconds))
        .append("\n");
    sb.append("    successfulJobsHistoryLimit: ")
        .append(toIndentedString(successfulJobsHistoryLimit))
        .append("\n");
    sb.append("    suspend: ").append(toIndentedString(suspend)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces (except the first line).
   */
  private String toIndentedString(java.lang.Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }
}
